import request from '@/config/axios'
import signMd5Utils from '@/utils/signMd5Utils'
import { serviceApiMonitor } from '@/config/axios/service'
import type { responseType } from './types'

const signHeader = (url: string, params: any) => {
  const sign = signMd5Utils.getSign(url, params)
  return { 'X-Sign': sign, 'X-TIMESTAMP': signMd5Utils.getDateTimeToString() }
}
// 获取时间
export const getSystemByToken = (params: any): Promise<LoginResponse> => {
  // const sign = signMd5Utils.getSign('/sys/permission/getUserPermissionByToken', params)
  // //将签名和时间戳，添加在请求接口 Header
  // const signHeader = { 'X-Sign': sign, 'X-TIMESTAMP': signMd5Utils.getDateTimeToString() }
  return request.get({
    url: '/sys/permission/getUserPermissionByToken',
    params,
    headers: signHeader('/sys/permission/getUserPermissionByToken', params)
  })
}
export const getSystemCpuCount = (params: any) => {
  return request.get({ url: '/actuator/metrics/system.cpu.count', params })
}
export const getSystemCpuUsage = (params: any): Promise<MonitorResponse<responseType>> => {
  return request.get({ url: '/actuator/metrics/system.cpu.usage', params })
}
export const getProcessStartTime = (params: any): Promise<MonitorResponse<responseType>> => {
  return request.get({ url: '/actuator/metrics/process.start.time', params })
}
export const getProcessUptime = (params: any): Promise<MonitorResponse<responseType>> => {
  return request.get({ url: '/actuator/metrics/process.uptime', params })
}
export const getProcessCpuUsage = (params: any): Promise<MonitorResponse<responseType>> => {
  return request.get({ url: '/actuator/metrics/process.cpu.usage', params })
}

/*
export const getSystemCpuCount = (params: any): Promise<MonitorResponse<responseType>> => {
  return serviceApiMonitor({
    method: 'get',
    url: '/actuator/metrics/system.cpu.count',
    params,
    headers: signHeader('/actuator/metrics/system.cpu.count', params)
  })
}
export const getSystemCpuUsage = (params: any): Promise<MonitorResponse<responseType>> => {
  return serviceApiMonitor({
    method: 'get',
    url: '/actuator/metrics/system.cpu.usage',
    params,
    headers: signHeader('/actuator/metrics/system.cpu.usage', params)
  })
}
export const getProcessStartTime = (params: any): Promise<MonitorResponse<responseType>> => {
  return serviceApiMonitor({
    method: 'get',
    url: '/actuator/metrics/process.start.time',
    params,
    headers: signHeader('/actuator/metrics/process.start.time', params)
  })
}
export const getProcessUptime = (params: any): Promise<MonitorResponse<responseType>> => {
  return serviceApiMonitor({
    method: 'get',
    url: '/actuator/metrics/process.uptime',
    params,
    headers: signHeader('/actuator/metrics/process.uptime', params)
  })
}
export const getProcessCpuUsage = (params: any): Promise<MonitorResponse<responseType>> => {
  return serviceApiMonitor({
    method: 'get',
    url: '/actuator/metrics/process.cpu.usage',
    params,
    headers: signHeader('/actuator/metrics/process.cpu.usage', params)
  })
}
*/
